/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Strategy;

import Adaptor.A_Changle;
import InterfaceClient.IChat;
import Packets.pkValue;
import StaticClass.ArrSocket;
import ThreadClient.ThreadMain;
import java.net.Socket;
import javax.swing.JFrame;

/**
 *
 * @author Oho
 */
public class SI_Chat implements SIPack {

    @Override
    public void check(pkValue vl, Socket sk, ThreadMain tm,String sv) {

        if (vl.getCommand() == 1 && ArrSocket.StateChat == false) {

            IChat ic1 = new InterfaceClient.IChat(tm);
            ic1.pack();
            ic1.setVisible(true);
            ArrSocket.StateChat = true;

            ArrSocket.ic = ic1;
        }
        if (vl.getObj().equals("QUIT")) {
            ArrSocket.ic.Quit();

        } else {
            ConvertPackage(vl, ArrSocket.ic, sv);
        }
        //ConvertPackage(vl, ArrSocket.ic.txtInput, null);
    }

    @Override
    public void ConvertPackage(pkValue pk, JFrame vic, String str) {
        System.out.println(str+": "+ pk.getObj());
        ArrSocket.ic.txtInput.append(str+": " + pk.getObj() + "\n");

    }
}
